package com.cuitrip.business.order.model;


import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;
import com.cuitrip.app.base.UnitUtils;
import com.cuitrip.business.tripservice.model.OtherNotes;
import com.cuitrip.business.tripservice.model.ServiceInfo;

import java.io.Serializable;

public class OrderItem implements Serializable {
    /**
     * 订单状态修改的action name
     */
    public static final String ORDER_STATUS_CHANGED_ACTION = "ct_order_status_changed";
    /**
     * 聊天未读消息有修改的action name
     */
    public static final String MESSAGE_UNREAD_COUNT_CHANGED_ACTION = "ct_message_unread_changed";

    /**
     * 订单信息的id
     */
    public static final String KEY_ORDER_ID = "order_id_key";

    public static final String KEY_ORDER_ITEM = "order_item_key";



    private static final long serialVersionUID = 1523183235771740008L;

    public static final int STATUS_NONE = 0;//无状态
    public static final int STATUS_WAIT_CONFIRM = 1;//等待确认
    public static final int STATUS_WAIT_PAY = 2;//等待支付
    public static final int STATUS_WAIT_START = 3;//等待开始
    public static final int STATUS_IN_PROGRESS = 4;//行程进行中
    public static final int STATUS_TRIP_FINISH = 5;//行程结束
    public static final int STATUS_OVER = 6;//行程评价完成
    public static final int STATUS_EXPIRED = 7;//行程失效
    public static final int STATUS_REFUND = 8;//行程退款
    public static final int STATUS_REFUND_FAIL = 9;//退款失败


    public static final int TYPE_NONE = 0;//无状态
    public static final int TYPE_CANCEL_INTERNAL = 1;//内部小二取消
    public static final int TYPE_CANCEL_TRAVELLER = 2;//旅行者取消
    public static final int TYPE_CANCEL_FINDER = 3;//发现者取消；
    public static final int TYPE_EXPIRED_CONFIRM = 4;//订单未确认 自动超时
    public static final int TYPE_EXPIRED_PAY = 5;//订单未支付 自动超时
    public static final int TYPE_EXPIRED_REFUNDED = 6;//退款成功订单自动失效
    protected String oid; //": "9_20150626221150_14",
    private int status; //: "7",
    protected String statusContent; //: "订单已关闭",
    protected int type; //": "0",
    protected String sid; //": "9",
    protected String insiderId; //": "13",
    protected String userNick; //": "Andy", 对方名字
    protected String headPic; //": "http://cuitrip.oss-cn-shenzhen.aliyuncs.com/14_1435329624387", 对方头像
    protected String insiderName; //": "Andy", 有时候返回空， 建议使用usernick
    protected String insiderSign; //": "再改一句",
    protected String travellerId; //": "14",
    protected String travellerName; //": "Andy", 不建议使用 ，有时候返回空 很蛋疼
    protected String paymentWay; //": "1",

    protected String serviceName; //": "bobby带你看花莲老火车",
    protected String serviceDate; //": "2015-06-29 00:00:00", 订单时间
    protected String servicePIC; //": "http://cuitrip.oss-cn-shenzhen.aliyuncs.com/13_1434945983861",
    protected String serviceAddress; //": "花莲",

    protected String orderPrice; //": "0",  paycurrency 支付价格
    protected String payCurrency;//orderprice

    protected String servicePrice; //": "200", 和moneytype对应
    protected String moneyType; //": "CNY", 和servicePrice, showPrice对应
    protected String buyerNum; //": "1", 没有单位
    protected String extInfo; //": "",
    protected String gmtCreated; //": "2015-06-26 22:11:50.0",
    protected String gmtModified; //": "2015-06-26 22:38:56.0"
    protected String comment;
    protected String score;
    protected String priceType;  // 免费/每人/所有
    protected String feeInclude;
    protected String feeExclude;
    protected String meetingPlace;
    protected String invalidReason;
    protected String lat;
    protected String lng;
    protected String targetId;//融云targetid
    protected String serviceTime;//游玩时间长度
    @JSONField(name = "otherNotes")
    protected OtherNotes otherNotes;
    protected String otherCity;
    protected String otherCareer;
    protected int leftDays;
    private String serviceFeeIsCharged;
    private String tranFeeIsCharged;


    @JSONField(name = "tranfee")
    protected String transactionFee;//手续费

    @JSONField(name = "servicefee")
    protected String platformFee;//平台费用
    @JSONField(name = "couponFee")
    protected String couponFee;//优惠费用
    protected String refundFee;//退回费用
    @JSONField(name = "cancelFee")
    protected String cancellationFee;//取消费用

    protected String showPrice;//显示费用

    protected String isOldVersion;//"0"/"1"
   /*
     * 之后默认false
     */
    private String showOldDialog = UnitUtils.BOOLEAN_FALSE;

    public String getServiceFeeIsCharged() {
        return serviceFeeIsCharged;
    }

    public void setServiceFeeIsCharged(String serviceFeeIsCharged) {
        this.serviceFeeIsCharged = serviceFeeIsCharged;
    }

    public String getTranFeeIsCharged() {
        return tranFeeIsCharged;
    }

    public void setTranFeeIsCharged(String tranFeeIsCharged) {
        this.tranFeeIsCharged = tranFeeIsCharged;
    }

    public String getIsOldVersion() {
        return isOldVersion;
    }

    public void setIsOldVersion(String isOldVersion) {
        this.isOldVersion = isOldVersion;
    }

    public String getShowOldDialog() {
        return showOldDialog;
    }

    public void setShowOldDialog(String showOldDialog) {
        this.showOldDialog = showOldDialog;
    }

    public boolean isOldConversations() {
        return UnitUtils.BOOLEAN_TRUE.equals(isOldVersion);
    }

    public boolean enableRongConversation() {
//        return true;
        return UnitUtils.BOOLEAN_FALSE.equals(showOldDialog);
    }

    public String getServiceTime() {
        return serviceTime;
    }

    public void setServiceTime(String serviceTime) {
        this.serviceTime = serviceTime;
    }

    public String getTargetId() {
        return targetId;
    }

    public void setTargetId(String targetId) {
        this.targetId = targetId;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng;
    }

    public String getFeeInclude() {
        return feeInclude;
    }

    public void setFeeInclude(String feeInclude) {
        this.feeInclude = feeInclude;
    }

    public String getFeeExclude() {
        return feeExclude;
    }

    public void setFeeExclude(String feeExclude) {
        this.feeExclude = feeExclude;
    }

    public String getMeetingPlace() {
        return meetingPlace;
    }

    public void setMeetingPlace(String meetingPlace) {
        this.meetingPlace = meetingPlace;
    }

    public String getInvalidReason() {
        return invalidReason;
    }

    public void setInvalidReason(String invalidReason) {
        this.invalidReason = invalidReason;
    }

    public String getPriceType() {
        return priceType;
    }

    public boolean isDiscount() {
        return "2".equals(paymentWay);
    }

    public boolean isPricePerMan() {
        return "1".equals(priceType);
    }

    public String getPayCurrency() {
        return payCurrency;
    }

    public void setPayCurrency(String payCurrency) {
        this.payCurrency = payCurrency;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public float getCommentScore() {
        try {
            return Float.valueOf(score);
        } catch (Exception e) {
            return -1;
        }
    }

    public void setCommentScore(String commentScore) {
        this.score = commentScore;
    }

    public boolean isClosed() {
        return (status == 6) || (status == 7);
    }

    public String getOid() {
        return oid;
    }

    public void setOid(String oid) {
        this.oid = oid;
    }

    /**
     * createOrder接口中为orderId
     *
     * @param orderId
     */
    public void setOrderId(String orderId) {
        this.oid = orderId;
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getStatusContent() {
        return statusContent;
    }

    public void setStatusContent(String statusContent) {
        this.statusContent = statusContent;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getInsiderId() {
        return insiderId;
    }

    public String getOtherId(String id) {
        if (id != null) {
            return id.equals(getInsiderId()) ? getTravellerId() : getInsiderId();
        }
        return null;
    }

    public void setInsiderId(String insiderId) {
        this.insiderId = insiderId;
    }

    public String getUserNick() {
        return userNick;
    }

    public void setUserNick(String userNick) {
        this.userNick = userNick;
    }

    public String getHeadPic() {
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }

    public String getInsiderName() {
        return insiderName;
    }

    public void setInsiderName(String insiderName) {
        this.insiderName = insiderName;
    }

    public String getInsiderSign() {
        return insiderSign;
    }

    public void setInsiderSign(String insiderSign) {
        this.insiderSign = insiderSign;
    }

    public String getTravellerId() {
        return travellerId;
    }

    public void setTravellerId(String travellerId) {
        this.travellerId = travellerId;
    }

    public String getTravellerName() {
        return travellerName;
    }

    public void setTravellerName(String travellerName) {
        this.travellerName = travellerName;
    }

    public String getPaymentWay() {
        return paymentWay;
    }

    public void setPaymentWay(String paymentWay) {
        this.paymentWay = paymentWay;
    }

    public String getMoneyType() {
        return moneyType;
    }

    public void setMoneyType(String moneyType) {
        this.moneyType = moneyType;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getServiceDate() {
        return serviceDate;
    }

    public void setServiceDate(String serviceDate) {
        this.serviceDate = serviceDate;
    }

    public String getServicePIC() {
        return servicePIC;
    }

    public void setServicePIC(String servicePIC) {
        this.servicePIC = servicePIC;
    }

    public String getServiceAddress() {
        return serviceAddress;
    }

    public void setServiceAddress(String serviceAddress) {
        this.serviceAddress = serviceAddress;
    }

    public String getOrderPrice() {
        return orderPrice;
    }

    public void setOrderPrice(String orderPrice) {
        this.orderPrice = orderPrice;
    }

    public String getServicePrice() {
        return servicePrice;
    }

    public void setServicePrice(String servicePrice) {
        this.servicePrice = servicePrice;
    }

    public String getBuyerNum() {
        return buyerNum;
    }

    public void setBuyerNum(String buyerNum) {
        this.buyerNum = buyerNum;
    }

    public String getExtInfo() {
        return extInfo;
    }

    public void setExtInfo(String extInfo) {
        this.extInfo = extInfo;
    }

    public String getGmtCreated() {
        return gmtCreated;
    }

    public void setGmtCreated(String gmtCreated) {
        this.gmtCreated = gmtCreated;
    }

    public String getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(String gmtModified) {
        this.gmtModified = gmtModified;
    }

    public void setPriceType(String priceType) {
        this.priceType = priceType;
    }

    public boolean isTypeFree() {
        return String.valueOf(ServiceInfo.PAYWAY_FREE).equals(priceType);
    }

    public int getLeftDays() {
        return leftDays;
    }

    public void setLeftDays(int leftDays) {
        this.leftDays = leftDays;
    }

    public OtherNotes getOtherNotes() {
        return otherNotes;
    }

    public void setOtherNotes(OtherNotes otherNotes) {
        this.otherNotes = otherNotes;
    }

    public String getOtherCity() {
        return otherCity;
    }

    public void setOtherCity(String otherCity) {
        this.otherCity = otherCity;
    }

    public String getOtherCareer() {
        return otherCareer;
    }

    public void setOtherCareer(String otherCareer) {
        this.otherCareer = otherCareer;
    }

    public String getTransactionFee() {
        return transactionFee;
    }

    public void setTransactionFee(String transactionFee) {
        this.transactionFee = transactionFee;
    }

    public String getCouponFee() {
        return couponFee;
    }

    public void setCouponFee(String couponFee) {
        this.couponFee = couponFee;
    }

    public String getPlatformFee() {
        return platformFee;
    }

    public void setPlatformFee(String platformFee) {
        this.platformFee = platformFee;
    }

    public String getRefundFee() {
        return refundFee;
    }

    public void setRefundFee(String refundFee) {
        this.refundFee = refundFee;
    }

    public String getCancellationFee() {
        return cancellationFee;
    }

    public void setCancellationFee(String cancellationFee) {
        this.cancellationFee = cancellationFee;
    }

    public String getShowPrice() {
        return showPrice;
    }

    public void setShowPrice(String showPrice) {
        this.showPrice = showPrice;
    }

    public boolean hasPay(){
        if (TextUtils.isEmpty(paymentWay) || "0".equals(paymentWay)){
            return false;
        }
        return true;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean isExpired(){
        if (TYPE_EXPIRED_CONFIRM == type || TYPE_EXPIRED_PAY == type || TYPE_EXPIRED_REFUNDED == type){
            return true;
        }
        return false;
    }


    public boolean isCancelled(){
        if (TYPE_CANCEL_FINDER == type || TYPE_CANCEL_INTERNAL == type || TYPE_CANCEL_TRAVELLER == type){
            return true;
        }
        return false;
    }
}
